﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AcadPos.Entity;
using System.Data.Common;

namespace AcadPosApp
{
    public partial class homeMobile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                Polo polo = new Polo();
                polo.IdEstado = 1;
                ddlPolo.DataSource = ControlClass.CNPolo.listaPolosEstado(polo);
                ddlPolo.DataTextField = "DESCRICAO";
                ddlPolo.DataValueField = "ID_POLO";
                ddlPolo.DataBind();
                ddlPolo.SelectedIndex = - 1;
            }
        }
         
        protected void ddlPolo_SelectedIndexChanged(object sender, EventArgs e)
        {
            int idPolo = Convert.ToInt32(ddlPolo.SelectedValue);
            gvwPolo.DataSource = ControlClass.CNPolo.listaInformacoesDoPolo(idPolo);
            gvwPolo.DataBind();
            gvwPolo.SelectedIndex = -1;
        }
        private decimal _valorTotal; 
        protected void gvwPolo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
                this._valorTotal += Convert.ToDecimal(e.Row.Cells[5].Text); //((GridViewRow)e.Row.DataItem).GetDecimal(5); 
            else if (e.Row.RowType == DataControlRowType.Footer)
                e.Row.Cells[5].Text = "TOTAL: " + this._valorTotal.ToString("");
        }

    }
}